

<div class="layui-form" lay-filter="layuiadmin-form-role" id="forms">
	<div class="form-cont" style="overflow: inherit;">
		<div class="layui-form-item verify">
		  <label class="layui-form-label">星期范围</label>
		  <div class="layui-input-block flex">
		      <div class="layui-unselect layui-form-select">
		      	<div class="layui-select-title"><input type="text" verify="require" name="start_week" placeholder="请选择星期" class="layui-input layui-unselect" readonly><i
		      		 class="layui-edge"></i></div>
		      	<dl class="layui-anim layui-anim-upbit">
		      		<dd class="layui-select-tips layui-this">请选择星期</dd>
		      		<dd :data='index' v-for="(x,index) in weeks">{{x.week}}</dd>
		      	</dl>
		      </div>
			   <span style="padding: 0 10px;">~</span> 
				<div class="layui-unselect layui-form-select">
					<div class="layui-select-title"><input type="text" verify="require" name="end_week" placeholder="请选择星期" class="layui-input layui-unselect" readonly><i
						 class="layui-edge"></i></div>
					<dl class="layui-anim layui-anim-upbit">
						<dd class="layui-select-tips layui-this">请选择星期</dd>
						<dd :data='index' v-for="(x,index) in weeks">{{x.week}}</dd>
					</dl>
				</div>
				<span class="hint">星期范围必选</span>
		  </div>
		</div>
		<div class="layui-form-item verify">
		  <label class="layui-form-label">计费时段</label>
		  <div class="layui-input-block flex">
			  <div class="layui-unselect layui-form-select">
				<div class="layui-select-title"><input type="text" verify="require" name="start_time" placeholder="请选择时间" class="layui-input layui-unselect" readonly><i
					 class="layui-edge"></i></div>
				<dl class="layui-anim layui-anim-upbit">
					<dd class="layui-select-tips layui-this">请选择时间</dd>
					<dd :data='index' v-for="(x,index) in times">{{x.time}}</dd>
				</dl>
			  </div>
			   <span style="padding: 0 10px;">~</span> 
				<div class="layui-unselect layui-form-select">
					<div class="layui-select-title"><input type="text" verify="require" name="end_time" placeholder="请选择时间" class="layui-input layui-unselect" readonly><i
						 class="layui-edge"></i></div>
					<dl class="layui-anim layui-anim-upbit">
						<dd class="layui-select-tips layui-this">请选择时间</dd>
						<dd :data='index' v-for="(x,index) in times">{{x.time}}</dd>
					</dl>
				</div>
				<span class="hint">计费时段必选</span>
		  </div>
		</div>
		<div class="layui-form-item verify">
		  <label class="layui-form-label">金额(元)</label>
		  <div class="layui-input-block">
			  <input type="number" verify="require|znum" v-model="detail.time_money" placeholder="请输入金额" class="layui-input">
			  <span class="hint">金额必填</span>
			</div>
		</div>
		<div class="layui-form-item">
		  <label class="layui-form-label">是否包时段</label>
		  <div class="layui-input-block">
			  <div class="layui-unselect layui-form-switch" :class="{'layui-form-onswitch':detail.status==1}" lay-skin="_switch" @click="radioF()"><em>{{detail.status==1?'是':'否'}}</em><i></i></div>
		  </div>
		</div>
	</div>
  <div class="form-btn">
      <input type="button" value="确认" class="layui-btn" @click="submit">
  </div>
</div>

<script>
	layui.use(['form'], function(){
	  var $ = layui.$
	  ,form = layui.form;
	  var forms=new Vue({
	  		el:'#forms',
	  		data:{
	  			detail:{
					status:2
				},
				times:[],
				time_detail:layui.admin.time_detail,
				weeks:[{week:'星期一'},{week:'星期二'},{week:'星期三'},{week:'星期四'},{week:'星期五'},{week:'星期六'},{week:'星期日'}]
	  		},
	  		mounted() {
				//初始化
	  			//if(this.type!=1) this.role=layui.admin.objData.detail;
				for(var i=0; i<25; i++){
					this.times.push({time:(i<10?'0'+i:i)+':00'})
				}
	  		},
	  		methods:{
	  			radioF(){//radio选择
	  				this.detail.status==1?this.detail.status=2:this.detail.status=1;
	  			},
				submit:function(){
					if(layui.admin.form('#forms')){
						/* if(parseInt($('input[name="start_week"]').attr('data'))>parseInt($('input[name="end_week"]').attr('data'))){
							
						} */
						Object.assign(this.detail,{
							start_time:$('input[name="start_time"]').val(),
							end_time:$('input[name="end_time"]').val(),
							start_week:$('input[name="start_week"]').val(),
							end_week:$('input[name="end_week"]').val()
						});
						this.time_detail.rule_desc.push(this.detail);
						layer.close(layui.admin.pups);
					}
				}
	  		}
	  	})
	});
</script>
